<template>
  <div class="dialog">
    <el-dialog
      title="委外维修处理"
      :visible.sync="showDialog"
      width="35%"
      top="0"
      :close-on-click-modal="false"
      @close="cancel"
    >
      <div class="meaasge-font">{{ '确定是否申请委外处理？' }}</div>
      <!-- <el-form
        ref="ruleForm"
        label-position="left"
        :model="formData"
        :rules="rules"
        class="el-form"
      >
        <el-form-item label="上报人：" class="w100p" prop="proposer">
          <el-select
            v-model="formData.proposer"
            clearable
            filterable
            placeholder="上报人选择"
          >
            <el-option
              v-for="item of userList"
              :key="item.userId"
              :label="item.username"
              :value="item.username"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="委外日期：" class="w100p" prop="applyDate">
          <el-date-picker
            v-model="formData.applyDate"
            type="date"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
            clearable
          />
        </el-form-item>
      </el-form> -->
      <div slot="footer" class="dialog-footer">
        <el-button class="cancelbtn" @click="cancel()">取 消</el-button>
        <el-button type="primary" class="savebtn" @click="save()">保 存</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import RepairHandleApi from "@/api/equip-repair-manage/repair-handle/index";
// import userApi from "@/api/system-settings/user-manage";

export default {
  name: '',
  components: { },
  props: {
    // 弹框名称
    show: {
      type: Boolean,
      default: false
    },
    editObject: {
      type: [Object],
      default: () => {
        return {}
      }
    }
  },
  data() {
    return {
      // formData: { },
      // rules: {
      //   applyDate: [
      //     { required: true, message: "请选择委外日期", trigger: ["change", "blur"] }
      //   ]
      // },
      showDialog: this.show
      // userList: []

    };
  },

  watch: {
    show(v) {
      this.showDialog = v;
      // if (v) {
      //   var day = new Date()
      //   this.formData.applyDate = this.$moment(day).format("YYYY-MM-DD");
      // }
    }
  },
  created() {
  },
  mounted() {
    // this.queryUserList()
  },
  methods: {

    // // 查询可选择维修人
    // queryUserList() {
    //   userApi.queryUserAll({}).then((res) => {
    //     if (res.code === 1) {
    //       let data = res.data || [];
    //       this.userList = data;
    //     }
    //   });
    // },
    save() {
      // this.$refs[formData].validate(valid => {
      //   if (valid) {
      // this.formData.hitchApplyAuditCode = this.editObject.hitchApplyAuditCode;
      // this.formData.repairNature = '委外维修'
      var params = {
        hitchApplyAuditCode: this.editObject.hitchApplyAuditCode,
        repairNature: '委外维修',
              personNo: sessionStorage.personNo,
              pass: false,
              farmingTypeNo: sessionStorage.farmingTypeNo,
              farming: sessionStorage.farming
      }
      // this.formData.hitchInfoBO = {
      //   hitchTypeCode: this.editObject.hitchTypeCode,
      //   hitchDescription: this.editObject.hitchDescription.toString(),
      //   equipmentCode: this.editObject.equipmentCode,
      //   equipmentName: this.editObject.equipmentName,
      //   discoverNodes: this.editObject.discoverNodes,
      //   organizationMark: sessionStorage.organizationNo,
      //   proposer: this.formData.proposer
      // }
      RepairHandleApi.addApplyOutNew(params).then(res => {
        if (res.code === 1) {
          this.$message.success("委外申请成功！");
          this.close()
        } else {
          this.$message.error("委外申请失败！");
        }
      });
      //   } else {
      //     return false;
      //   }
      // });
    },
    close() {
      this.$emit("closeDialog");
    },
    cancel() {
      this.$emit("cancelDialog");
    }
  }
};
</script>

<style lang="scss" scoped>
.meaasge-font{
  width: 100%;
  text-align: center;
  font-size: 20px;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}
</style>
